// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import 'element-ui/lib/theme-default/index.css';

import axios from 'axios';
import ElementUI from 'element-ui';
import moment from 'moment';
import Vue from 'vue';

import App from './App';
import ddapi from './auth/ddapi';
import router from './router';

require('es6-promise/auto');

Vue.config.productionTip = false
Vue.use(ElementUI)
Vue.prototype.$http = axios;
Vue.prototype.$ddapi = ddapi;

Vue.filter('formatDate', function (res) {
  if (res != null && res != '') {
    let timestap = new Date(res).getTime()
    return moment(timestap).format("YYYY-MM-DD");
  } else {
    return '';
  }
})

axios.interceptors.request.use(function (config) { // 这里的config包含每次请求的内容
  config.headers.Authorization = localStorage.getItem('token');
  return config;
}, function (err) {
  return Promise.reject(err);
});
// 全局钩子
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  template: '<App/>',
  components: {
    App
  }
})
